package com.bianmaba.examples;

import com.bianmaba.examples.service.authorization.user.UserService;
import com.bianmaba.spring.mvc.method.support.annotations.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.LinkedHashMap;
import java.util.Map;

@RestController
public class GlobalController {

    @Autowired
    private UserService userService;


    @RequestMapping({"get_localhost"})
    @JSON
    public String getLocalhost(HttpServletRequest request) {
        String host = request.getRemoteHost();
        return host;
    }


    @RequestMapping({"load_initial_information"})
    @JSON(excludeProperties = {"data.*\\.projectOrder", "data.*\\.iterations", "data.*\\.children"})
    public Object loadInitialInformation(HttpServletRequest request) {
        Map<String, Object> inf = new LinkedHashMap<String, Object>(0);

        String host = getLocalhost(request);
        inf.put("localhost", host);
        return inf;
    }


}
